package com.yundingai.controller;

import com.yundingai.domain.entity.UserSocialData;
import com.yundingai.service.UserSocialDataService;
import com.yundingai.vm.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author HuangZhengmin
 * @desc
 * @Date 2025/7/25 16:56
 * @Version 1.0
 */
@RestController
@RequestMapping("/socialData")
public class UserSocialDataController {
  @Autowired
  private UserSocialDataService userSocialDataService;

  /**
   * 添加用户社交数据
   * @param userSocialData
   */
  @PostMapping("/add")
  public ResponseResult add(@RequestBody UserSocialData userSocialData){
    return ResponseResult.okResult(userSocialDataService.save(userSocialData));
  }

  /**
   *  更新用户社交数据
   * @param userSocialData
   */
  @PutMapping("/update")
  public ResponseResult update(@RequestBody UserSocialData userSocialData){
    userSocialDataService.updateByUserId(userSocialData);
    return ResponseResult.okResult();
  }

  /**
   *  删除用户社交数据
   * @param userId
   */
  @DeleteMapping("/{userId}")
  public ResponseResult delete(@PathVariable("userId") Integer userId){
    userSocialDataService.removeByUserId(userId);
    return ResponseResult.okResult();
  }

  /**
   *  根据用户id查询社交数据
   * @param userId
   */
  @GetMapping("/{userId}")
  public ResponseResult query(@PathVariable("userId") Integer userId){
    return ResponseResult.okResult(userSocialDataService.queryByUserId(userId));
  }

}
